package addon.w3.mdx.com;

import java.io.IOException;

import addon.w3.mdx.MDXCOM;
import addon.w3.mdx.LEDataInputStream;
import addon.w3.mdx.MDXException;
/**
--PVTX						// [Faces]
	long	ntris;
	short	triangles[ntris];
 * @author madjk
 *
 */
public class MDXFacesCOM extends MDXCOM {
	int length = -1;
	public short triangles[][] = null;
	
	public String getTag() {
		return "PVTX";
	}
	
	public void _decode(LEDataInputStream ins) throws IOException, MDXException {
		length = ins.readInt();
		triangles = new short[length/3][3];
		for (int i = 0; i < triangles.length; i++) {
			triangles[i][0] = ins.readShort();
			triangles[i][1] = ins.readShort();
			triangles[i][2] = ins.readShort();
		}
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("TAG : "+getTag());
		sb.append("\n\tILEN : "+length);
		if(triangles != null && triangles.length > 0) sb.append("\n\tTRIANGLES[] : "+triangles.length);
		return sb.toString();
	}

	@Override
	public boolean isImplicitTag() {
		// TODO Auto-generated method stub
		return true;
	}
}

//public class MDXFacesCOM extends MDXCOM {
//	int length = -1;
//	public short triangles[] = null;
//	
//	public String getTag() {
//		return "PVTX";
//	}
//	
//	public void _decode(MDXDataInputStream ins) throws IOException, MDXException {
//		length = ins.readInt();
//		triangles = new short[length];
//		for (int i = 0; i < triangles.length; i++) {
//			triangles[i] = ins.readShort();
//		}
//	}
//	
//	public String toString() {
//		StringBuffer sb = new StringBuffer();
//		sb.append("TAG : "+getTag());
//		sb.append("\n\tILEN : "+length);
//		if(triangles != null && triangles.length > 0) sb.append("\n\tTRIANGLES[] : "+triangles.length);
//		return sb.toString();
//	}
//}
